package translate;

import temp.Label;
import tree.BasicExp;
import tree.BasicStm;
import tree.CJUMP;
import tree.CONST;
import tree.ExpList;

public class StringCompExp extends Cx {
	frame.Frame frame;
	Exp left, right;
	int type;
	
	public StringCompExp(Level lev, Exp l, Exp r, int t) {
		super();
		frame = lev.frame;
		left = l;
		right = r;
		type = t;
	}
	
	BasicStm unCx(Label t, Label f) {
		if (type < 2) {
			BasicExp call = frame.externalCall("stringEqual", new ExpList(left.unEx(), new ExpList(right.unEx(), null)));
			
			if (type == 0)
				return new CJUMP(CJUMP.EQ, call, new CONST(0), t, f);
			if (type == 1)
				return new CJUMP(CJUMP.NE, call, new CONST(0), t, f);
		}
		
		return null;
	}
}
